//
//  XMSendStatusTool.m
//  XMWeibo
//
//  Created by chi on 14-8-30.
//  Copyright (c) 2014年 xiaoming. All rights reserved.
//

#import "XMSendStatusTool.h"
#import "XMHttpTool.h"
#import "MJExtension.h"

@implementation XMSendStatusTool


/**
 *  发送一条不带图片微博
 *
 *  @param params    请求参数
 *  @param success   请求结果
 *  @param failure   失败参数
 */
+ (void)sendStatusWithParam:(XMHttpSendStatusParams *)params success:(void (^)(XMHttpSendStatusResult *))success failure:(void (^)(NSError *))failure
{

    [XMHttpTool httpPostWithURL:k_statuses_update params:params.keyValues success:^(id responseObject) {
        // 请求成功
        XMHttpSendStatusResult *result = [XMHttpSendStatusResult objectWithKeyValues:responseObject];
        success(result);

    } failure:^(NSError *error) {
        // 请求失败
        failure(error);

    }];

}


+ (void)sendStatusWithParam:(XMHttpSendStatusParams *)params formDatas:(NSArray *)formDatas success:(void (^)(XMHttpSendStatusResult *))success failure:(void (^)(NSError *))failure
{
    for (XMHttpFormData *formData in formDatas) {
        formData.mimeType = @"image/jpeg";
        formData.name = @"pic";
        formData.fileName = @"xmweibo";
    }
    
    [XMHttpTool httpPostWithURL:k_tatuses_upload params:params.keyValues formDatas:formDatas success:^(id responseObject) {
        // 请求成功
        XMHttpSendStatusResult *result = [XMHttpSendStatusResult objectWithKeyValues:responseObject];
        success(result);
    } failure:^(NSError *error) {
        // 请求失败
        failure(error);
    }];
}

@end
